<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>


<script type="text/javascript" src="js/jquery.itextclear.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea', '.form').iTextClear();
    });
</script>
<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="${ctx}/css/Tree.css"/>
<!-- jQplot CSS END -->

<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>
<script type="text/javascript" src="lib/datatables/js/jquery.dataTables.js"></script>
<script type="text/javascript">
    /*$(document).ready(function() {
        $('#example').dataTable({
            "sPaginationType": "full_numbers"
        });
    });*/
</script>
<!-- DATATABLES CSS END -->

<h1 class="page-title">工作说明书设置</h1>

<div class="container_12 clearfix leading">

    <div class="tabs side grid_8 leading">
        <div class="grid_12">

            <div id="demo" class="clearfix">
                <table class="display" id="example">
                    <thead>
                    <tr>
                        <th>选择</th>
                        <th>岗位名称</th>
                        <th>编制人数</th>
                        <th>岗位职责</th>
                        <th>查看说明书</th>
                    </tr>
                    </thead>
                    <tbody>
                    <s:iterator value="#request.jobSpecificationPojos" var="j" status="sta">
                    <s:if test="#sta.even"> <tr class="gradeA"> </s:if><s:else><tr class="gradeC"></s:else>
                        <td><input type="checkbox" name="checkbox_job_specification" value="${j.jid}"/></td>
                        <td>${j.dutyName}</td>
                        <td>${j.count}</td>
                        <td>${j.content}</td>
                        <s:if test="#request.j.jid == null">
                        <td><a class="button" href="#rank/job_specification_add.xhtml?currentDutyId=${j.dutyId}&t=<%=new java.util.Date().getTime()%>"><span style="background:url(${ctx}/images/img/page_edit.png)" class="icon">&nbsp;</span>请填写说明书</a></td>
                        </s:if>
                        <s:else>
                            <s:if test="#request.j.status.toString() == 'wait_audit'">
                            <td><a class="button" href="#rank/job_specification_add.xhtml?jobSpecification.id=${j.jid}&t=<%=new java.util.Date().getTime()%>"><span style="background:url(${ctx}/images/img/script_error.png)" class="icon">&nbsp;</span>未审核</a></td>
                            </s:if>
                            <s:else>
                            <td><a class="button" href="#rank/job_specification_view.xhtml?jobSpecification.id=${j.jid}&operation=set&t=<%=new java.util.Date().getTime()%>"><span style="background:url(${ctx}/images/img/zoom.png)" class="icon">&nbsp;</span>查看说明书</a></td>
                            </s:else>
                        </s:else>
                    </tr>
                    </s:iterator>
                    </tbody>
                </table>
            </div>
            <div class="form-action clearfix">
                <p style="margin-top: 10px">
                    <input type="checkbox" id="check_all" value="1" onchange="checkAll(this, 'checkbox_job_specification')"/><label for="check_all">全选</label>
                    <button class="button" type="button" onclick="deleteCheckedData()">批量删除</button>
                </p>
            </div>

        </div>


    </div>
</div>

<div class="clear"></div>


<script type="text/javascript" src="js/Tree.js"></script>
<script type="text/javascript" src="${ctx}/js/global_util.js"></script>
<script type="text/javascript">
    $(function(){
        onDutySelChange();
    });
    function onDutySelChange(){
        var dutyId = $("#duty_sel").val();
        if(dutyId > 0){
            $("#add_btn").attr("href", "#rank/job_specification_add.xhtml?currentDutyId="+dutyId);
        }
    }
    function deleteCheckedData(){
        var checkIds = new Array();
        $("input[type='checkbox'][name='checkbox_job_specification']").each(function(){
            if(this.checked && this.value > 0){
                checkIds.push(this.value);
            }
        });
        if(checkIds.length == 0){
            if($("input[type='checkbox'][name='checkbox_job_specification']").length > 0){
                alert("工作说明书未添加");
            }
            return;
        }
        if(confirm("确定要删除选中的数据吗？")){
            doDelete(checkIds.join(","))
        }
    }
    function doDelete(ids){
        var url = "${ctx}/rank/job_specification_delete.xhtml";
        refreshListContent(url, {"organizationId":"${organizationId}", "jobSpecificationIds":ids});
    }
</script>

    